package demo3;

import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: atp
 * Date: 2022-10-30
 * Time: 18:04
 */
class Person {
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public boolean equals(Object obj) {
        Person per = (Person) obj;
        if(this.name.equals(per.name) && this.age == per.age) {
            return true;
        }
        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }
}

    class Student {

    }

    public class Test7 {
        public static void main(String[] args) {
            Person person1 = new Person("张三", 18);
            Person person2 = new Person("张三", 18);
            System.out.println(person1.equals(person2));
        }
    }

